const mongoose = require('mongoose')

const ClusterSchema = new mongoose.Schema(
  {
    host: {
      type: String,
      required: true,
      unique: true,
      trim: true
    },
    onlineStatus: {
      type: Boolean,
      default: true
    },
    lastHeartbeat: {
      type: Number,
      default: Date.now()
    },
    onlineTime: {
      type: Number,
      default: 0
    },
    port: {
      type: Number,
      required: true
    },
    protocol: {
      type: String,
      required: true
    },
    performance: {
      gpuTotal: Number,
      gpuUsage: Number,
      memoryTotal: Number,
      memoryUsage: Number
    }
  },
  {
    timestamps: true // 开启自动生成时间戳
  }
)

const Cluster = mongoose.model('Cluster', ClusterSchema)
module.exports = Cluster
